#include "cpu/exec/template-start.h"

#define instr cmp

static void do_execute(){
	DATA_TYPE ret = op_dest -> val - op_src -> val;
	cpu.eflags.ZF = !ret;
	cpu.eflags.CF = op_dest -> val < op_src -> val;
	cpu.eflags.SF = ret >> ((DATA_BYTE << 3) - 1);
	//update_eflags_pf_zf_sf(ret);
	//cpu.eflags.OF = MSB((op_dest -> val ^ op_src -> val) & (op_dest -> val ^ ret));
	//cpu.eflags.ZF = !ret;
	//cpu.eflags.SF = ret >> ((DATA_BYTE << 3) - 1);
	int t1 = (op_dest -> val) >> ((DATA_BYTE << 3) - 1);
	int t2 = (op_src -> val) >> ((DATA_BYTE << 3) - 1);
	cpu.eflags.OF = (t1 != t2 && t2 == cpu.eflags.SF);
	ret ^= ret >> 4;
	ret ^= ret >> 2;
	ret ^= ret >> 1;
	ret &= 1;
	cpu.eflags.PF = !ret;
	/*if(((op_dest -> val & 0xf) - (op_src -> val & 0xf)) >> 4)
		cpu.eflags.AF = 1;
	else
		cpu.eflags.AF = 0;*/
	print_asm_template2();
}

make_instr_helper(i2a)
make_instr_helper(i2rm)
make_instr_helper(r2rm)
make_instr_helper(rm2r)
#if DATA_BYTE == 2 || DATA_BYTE == 4
make_instr_helper(si2rm)
#endif

#include "cpu/exec/template-end.h"
